//项目中所有的接口请求都在这里
import instance from "./request";

//定义请求接口
//首页 请求
export function getIndexData(params){
    return instance({
        url:'/index/index',
        method:'get',
        params:params
    })
}
//专题请求
export function getTopicData(params){
    return instance({
        url:'/topic/list',
        method:'get',
        params:params
    })
}

//分类页请求
export function getCategoryData(params){
    return instance({
        url:'/catalog/index',
        method:'get',
        params:params
    })
}
//当前分类页请求
export function getCurrentCategory(params){
    return instance({
        url:'/catalog/current',
        method:'get',
        params:params
    })
}
//购物车页请求
export function getCarData(params){
    return instance({
        url:'/cart/index',
        method:'get',// get 请求属性名为params
        params:params
        // headers: {
        //     'X-Nideshop-Token': localStorage.getItem('token')
        // }
    })
}



//我的页请求
export function loginFn(params){
    return instance({
        url:'/auth/loginByWeb',
        method:'post',
        data:params, //post 请求参数属性名必须是data
        Headers:{'content-type': 'application/json'}
    })
}

//定义搜索接口请求
//根据搜索的关键字进行搜索
export function searchgoods(params){
    return instance({
        url:'/goods/list',
        method:'get',
        params:params
    })
}
//详情页请求
export function getDetail(params) {
    return instance({
        url: '/goods/detail',
        method: 'get',
        params: params,

    })
}
//加入购物车请求
export function addCarData(params) {
    return instance({
        url: '/cart/add',
        method: 'post',
        data: params,
        headers: { 'content-type': 'application/json' }
    })
}
// 获取购物车商品的总数量
export function getGoodsCount(params) {
    return instance({
        url: '/cart/goodscount',
        method: 'get',
        params: params,
    })
}



